//
//  ViewController.m
//  UI02_UILabel_UITextField_UIButton_UIImageHomeworkFirst
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "ViewController.h"
#import "SILabel.h"
#import "SITextField.h"
#import "SIButton.h"
@interface ViewController ()<UITextFieldDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatLabelWithFrame:CGRectMake(70, 70, 100, 30) withText:@"用户名"];
    [self creatLabelWithFrame:CGRectMake(70, 140, 100, 30) withText:@"密码"];
    [self creatLabelWithFrame:CGRectMake(70, 210, 100, 30) withText:@"确认密码"];
    [self creatLabelWithFrame:CGRectMake(70, 280, 100, 30) withText:@"手机号"];
    [self creatLabelWithFrame:CGRectMake(70, 350, 100, 30) withText:@"邮箱"];
    
    [self creatTextFieldWithFrame:CGRectMake(180, 65, 200, 40) withText:@"请输入用户名"];
    [self creatTextFieldWithFrame:CGRectMake(180, 135, 200, 40) withText:@"请输入密码"];
    [self creatTextFieldWithFrame:CGRectMake(180, 205, 200, 40) withText:@"再次输入密码"];
    [self creatTextFieldWithFrame:CGRectMake(180, 275, 200, 40) withText:@"请输入联系方式"];
    [self creatTextFieldWithFrame:CGRectMake(180, 345, 200, 40) withText:@"请输入邮箱"];
    
    [self creatButton:CGRectMake(80, 450, 100, 80) withText:@"注册"];
    [self creatButton:CGRectMake(200, 450, 100, 80) withText:@"登录"];
}

-(void)creatLabelWithFrame:(CGRect)frame withText:(NSString *)text{
    SILabel *label = [[SILabel alloc] initWithFrame:frame withText:text];
    [self.view addSubview:label];
    [label release];
}

-(void)creatTextFieldWithFrame:(CGRect)frame withText:(NSString *)text{
    SITextField *allTextField = [[SITextField alloc] initWithFrame:frame withText:text];
    [self.view addSubview:allTextField];
    [allTextField release];
    allTextField.delegate = self;
}

-(BOOL)textFieldShouldReturn:(SITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}

-(void)creatButton:(CGRect)frame withText:(NSString *)text{
    SIButton *button = [SIButton buttonWithFrame:frame withText:text];
    [self.view addSubview:button];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
